/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Analysis;

/**
 *
 * @author asfeor
 */
import java.io.*;
import java.util.ArrayList;
import java.util.regex.*;
interface  NameFindFilte {
   
    public boolean acsept(String expr, String name);
    public void Find(String expr, String dir);
}

public class NameFindFilter implements NameFindFilte{
 private   ArrayList <String> List = new ArrayList<String>();

  @Override
public boolean  acsept(String expr, String name){
  boolean acses=Pattern.compile(expr).matcher(name).matches();    
return acses;        
}

 @Override
public void Find(String dir, String expr) {

File f = new File(dir);
try{
String[] sDirList = f.list();
int i;
for(i = 0; i < sDirList.length; i++){
 File f1 = new File(dir+File.separator+sDirList[i]);
if (acsept(expr, sDirList[i])) List.add("Absolute path "+f1.getAbsolutePath()+"\n Name "+f1.getName()+
                                            "\n Size"+f1.length()/1024+"\n Last modification"+
                                            new java.util.Date(f1.lastModified()));     
if(f1.isDirectory()) { Find(dir+File.separator+sDirList[i],expr);}        
} } catch (NullPointerException e){ List.add("Closed or damaged "+f.getAbsolutePath());}
}
 
public void Output(){
for (String lst: List){
    System.out.println(lst);
}    
} 
}